[#assign menucode="productList"]
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" />
    <meta name="description" content="安装通（azt365.com）中国大型的b2b电子商务智慧化平台,整合了国内安装行业内采购商与供应商,打通上下游产业链,信息透明共享,通过云平台,大数据,为各大企业供应商提供产品信息、企业推广,为您提供全面的安装行业资讯金融服务以及线上支付.">
    <meta name="keywords" content="安装通,azt365,江苏b2b电子商务,江苏建筑采供批发平台,江苏弱电批发,江苏消防报警系统,江苏智慧安装建筑安装,江苏安防监控系统,江苏通风设备安装,江苏通风工程安装,江苏通风工程施工,江苏消防工程材料批发,江苏消防工程材料">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <title>卖家中心-全部产品</title>
    <link href="/res/css/common/fenYe.css" rel="stylesheet">  
    <link href="/res/css/respective/company/aztCom.css" rel="stylesheet">
    <link href="/res/css/mall/mall.css" rel="stylesheet">
    <style type="text/css">
        .backfoot.pd0{
            padding-left: 200px;
        }
        td[rowspan]{
            border-left: 1px solid #ebebeb;
        }
        .fenye .fll{
        	float: left;
        	text-align: left;
        }
        .mainContent .goFenYe input.all{
        	height: auto;
		    width: auto;
		    margin-left: 10px;
        }
         .mainContent .goFenYe a.opGod{
         	display: inline-block;
		    width: 105px;
		    height: 25px;
		    line-height: 25px;
		    background-color: white;
		    color: #666666;
         } 
         .warp.warp-supplier .back-main .mainContent .goFenYe a.opGod{
         	margin-left: 10px;
         }
         .warp.warp-supplier .back-main .mainContent .goFenYe a.opGod:hover{
          	color: rgb(255, 192, 1);
          	border-color: rgb(255, 192, 1); 
          }
          .opGodTop{
          	margin-top: 10px;
          }
          .opGodTop input{
          	margin-left: 10px;
          }
          .opGodTop a{
          	display: inline-block;
		    width: 105px;
		    height: 25px;
		    line-height: 25px;
		    background-color: white;
		    color: #666666;
		    border: 1px solid #ebebeb;
		    padding: 0 6px;
		    margin-left: 10px;
		    text-align: center;
          }
          .warp.warp-supplier .back-main .mainContent .opGodTop a:hover{
          	border-color: rgb(255, 192, 1);;
          }
    </style>
</head>
<body>
<div class="coverDiv"></div>
<div class="warp">
[#include "/front/common/front_headAzt.html"]
    <div class="backcontent">
    [#include "/front/common/front_leftAzt.html"]
        <div class="back-main">
            <div class="mainContent">
                <div class="mainContentWhite">
                    <h1>商品管理
                        <button class="faBu" type="button" onclick="window.open('/product/chooseCate')">发布商品</button>
                    </h1>
                    <hr>
                    <div class="backTab">
                        <ul>
                            <li data-tab="1" [#if tab == 1]class="on"[/#if]>已上架</li>
                            <li data-tab="2" [#if tab == 2]class="on"[/#if]>待审核<span class="orange"><i></i>${auditCount!}</span></li>
                            <li data-tab="3" [#if tab == 3]class="on"[/#if]>已下架 </li>
                            <li data-tab="4" [#if tab == 4]class="on"[/#if]>未通过审核 </li>
                        </ul>
                    </div>
                    <div class="lableIterm">
                        <form action="/product/list" method="get" id="searchForm">
                            <input type="hidden" name="tab" value="${tab!}">
                            <input type="text" placeholder="请输入商品名称" value="${param.keyword!}" name="keyword">
                            <input type="hidden" id="pageNo" name="pageNo">
                            <button type="submit" class="search" onclick="search()">搜索</button>
                        </form>
                    </div>
                        [#--[#if data?? && data.list?? && data.list?size > 0]
						<div class="opGodTop">
							<input class="all" type="checkbox" onclick="check(this)" data-check="all">
							<dfn>全选</dfn>
                            [#if tab == 1]
							<a class="opGod" href="javascipt:void(0)" onclick="upDownProduct(2)">下架所选商品</a>
                            [#elseif tab == 3]
                            <a class="opGod" href="javascipt:void(0)" onclick="upDownProduct(1)">上架所选商品</a>
                            [/#if]
                            <a class="opGod" href="javascipt:void(0)" onclick="removeProduct()">删除所选商品</a>
						</div>
                        [/#if]--]
						<table class="refChose" style="border-bottom: 1px solid #ebebeb;margin-top: 4px;" id="proTable">
                        <thead>
                        <tr>
                            <th class="fir" style="width: 25%;">商品名称</th>
                            <th style="width: 15%;">商品分类</th>
                            <th style="width: 10%;">品牌</th>
                            <th style="width: 10%;">市场价</th>
                            <th style="width: 10%;">会员价</th>
                            <th style="width: 10%;">库存</th>
                            <th style="width: 10%;">状态</th>
                            <th style="width: 10%;">操作</th>
                        </tr>
                        </thead>
                        <tbody>

                        [#if data?? && data.list?? && data.list?size > 0]
                        [#list data.list as pro]
                            <tr data-proid="${pro.id!}">
                                <td class="fir" style="width: 20%;">
                                    <input type="checkbox" data-check="single" onclick="check(this)">
                                    <div class="malNameOuter">
                                        <p class="malName" [#if tab == 1 || tab == 3]onclick="window.open('/offer/${pro.id!}.html')"[/#if]>
                                            <img alt="" src="${pro.picPath?split(';')[0]}"/>
                                        </p>
                                    </div>
                                    <div class="malIntro" title="${pro.name!}">
                                        [#if tab == 1 || tab == 3]
                                            <a style="width: 130px;display: inline-block;" href="/offer/${pro.id!}.html" target="_blank">[@content_cut content=pro.name!/]</a>
                                        [#else]
                                            [@content_cut content=pro.name!/]
                                        [/#if]
                                    </div>
                                </td>
                                <td title="${pro.cateName!}">${pro.cateName!}</td>
                                <td>${pro.brandName!}</td>
                                <td class="bold">[#if pro.price??]￥${pro.price?string('0.00')!}[/#if]</td>
                                <td class="boldOrg">[#if pro.memberPrice??]￥${pro.memberPrice?string('0.00')!}[/#if]</td>
                                <td>${pro.stockQuantity!0}</td>
                                <td>
                                    [#if pro.ifPub == 1]
                                    [#if pro.state == 1]
                                        <img class="state" alt="" src="/res/images/oparaStatus/stateIcon_06.png"/>
                                        <dfn>已上架</dfn>
                                        [#elseif pro.state == 0 || pro.state == 3]
                                            <img class="state" alt="" src="/res/images/oparaStatus/stateIcon_03.png"/>
                                            <dfn>待审核</dfn>
                                        [#elseif pro.state == 2]
                                            <img class="state" alt="" src="/res/images/oparaStatus/stateIcon_08.png"/>
                                            <dfn onmouseover="layer.tips('${pro.auditOpinion!}', this, {tips: [3, '#666666']})" onmouseout="layer.closeAll('tips')">未通过审核</dfn>
                                    [/#if]
                                    [#else]
                                        <img class="state" alt="" src="/res/images/oparaStatus/stateIcon_10.png"/>
                                        <dfn>已下架</dfn>
                                    [/#if]
                                </td>
                                <td>
                                    [#if tab == 1]
                                        <a href="javascript:void(0)" onclick="upDownProduct(2, '${pro.id!}')">下架</a>
                                    [/#if]
                                    [#if tab == 3]
                                        <a href="javascript:void(0)" onclick="upDownProduct(1, '${pro.id!}')">上架</a>
                                    [/#if]
                                    <a href="javascript:void(0)" onclick="editProduct('${pro.id!}', '${tab!}')">编辑</a>
                                    <a href="javascript:void(0)" onclick="removeProduct('${pro.id!}')">删除</a>
                                </td>
                            </tr>
                        [/#list]
                        [#else]
                        <tr>
                            <td colspan="8">
                                当前没有任何商品信息~
                            </td>
                        </tr>
                        [/#if]

                        </tbody>
                        [#if data?? && data.list?? && data.list?size > 0]
							<tfoot class="goFenYe"> 
								<tr>
									<td class="fenye" colspan="100" style="text-align: right; background: #f8f8f8; font-size: 12px;">
										<div class="fll">
											<input class="all" type="checkbox" data-check="all" onclick="check(this)"/>
											<dfn>全选</dfn>
                                            [#if tab == 1]
											<a class="opGod" href="javascipt:void(0)" onclick="upDownProduct(2)">下架所选商品</a>
                                            [#elseif tab == 3]
                                            <a class="opGod" href="javascipt:void(0)" onclick="upDownProduct(1)">上架所选商品</a>
                                            [/#if]
											<a class="opGod" href="javascipt:void(0)" onclick="removeProduct()">删除所选商品</a>
										</div>
										共 ${data.total!} 条记录&nbsp;&nbsp;&nbsp;&nbsp;
                                        <span style="color: rgb(254, 169, 16); vertical-align: initial;">${data.pageNum!}</span>
										/ ${data.pages!} <input type="text" id="goPage" style="padding-left: 15px;">
										<button onclick="goPage()" type="button">GO</button>
                                        <a href="javascript:[#if data.hasPreviousPage]goPage(${data.prePage!})[#else]void(0)[/#if]">&lt;</a>
                                        <a href="javascript:[#if data.hasNextPage]goPage(${data.nextPage!})[#else]void(0)[/#if]" style="margin-right: 15px;">&gt;</a>
									</td>
								</tr> 
							</tfoot>
							[/#if]
                    </table> 
                </div>
            </div>
        </div>
    </div>
</div>
[#include "/front/common/front_footerAzt.html"]

<script src="/res/third/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
       $('.backTab li[data-tab]').on('click', function() {
           var tab = $(this).attr('data-tab');
           $('#searchForm input[name=tab]').val(tab);
           $('#searchForm input[name=keyword]').val('');
           $('#searchForm').submit();
       });
    });

    function check(obj) {
        var type = $(obj).attr('data-check');
        if(type == 'all') {
            $('#proTable input[type=checkbox][data-check=single]').prop('checked', $(obj).prop('checked'));
            $('input[type=checkbox][data-check=all]').prop('checked', $(obj).prop('checked'));
        } else {
            $('input[type=checkbox][data-check=all]').prop('checked',
                    $('#proTable input[type=checkbox][data-check=single]').length == $('#proTable input[type=checkbox][data-check=single]:checked').length);
        }
    }

    function upDownProduct(type, productId) {
        var str = '该';
        if(!productId) {
            //获取勾选的商品
            productId = $.map($('#proTable input[type=checkbox][data-check=single]:checked'), function(v) {
                return $(v).parents('tr').attr('data-proid');
            }).join(',');
            str = '这些';
        }
        if(productId == '') {
            layer.alert('请选择需要' + (type == 1 ? '上架' : '下架') + '的商品');
            return;
        }
        layer.confirm("确定要" + (type == 1 ? '上架' : '下架') + str + "商品吗？", function() {
            $.ajax({
                url: '/product/upDownProduct',
                type: 'post',
                dataType: 'json',
                data: {productId: productId, type: type},
                beforeSend: function () {
                    layer.load(2, {shade: 0.1});
                },
                success: function (res) {
                    if (res && res.success) {
                        layer.alert('操作成功', {closeBtn: 0}, function () {
                            location.reload();
                        });
                    } else {
                        layer.alert('操作失败');
                    }
                },
                complete: function () {
                    layer.closeAll('loading');
                }
            });
        });
    }

    function removeProduct(productId) {
        var str = '该';
        if(!productId) {
            //获取勾选的商品
            productId = $.map($('#proTable input[type=checkbox][data-check=single]:checked'), function(v) {
                return $(v).parents('tr').attr('data-proid');
            }).join(',');
            str = '这些';
        }
        if(productId == '') {
            layer.alert('请选择需要删除的商品');
            return;
        }
        layer.confirm("确定要删除" + str + "商品吗？", function() {
            $.ajax({
                url : '/product/removeProduct',
                type : 'post',
                dataType : 'json',
                data : {productId : productId},
                beforeSend : function() {
                    layer.load(2, {shade: 0.1});
                },
                success : function(res) {
                    if(res && res.success) {
                        layer.alert('操作成功', {closeBtn: 0}, function () {
                            location.reload();
                        });
                    } else {
                        layer.alert('操作失败');
                    }
                },
                complete : function() {
                    layer.closeAll('loading');
                }
            });
        });
    }

    function editProduct(productId, tab) {
        if(tab == 1) {
            layer.alert('请先下架该商品');
        } else {
            window.open('/product/publish?productId=' + productId);
        }
    }

    function goPage(pageNo) {
        if (!pageNo) {
            pageNo = $("#goPage").val();
            if (isNaN(pageNo)) {
                alert("跳转的页码必须为数字");
                return;
            }
            if (pageNo > ${data.pages!} || pageNo < 1) {
                alert("跳转的页码必须在范围之内");
                return;
            }
        }
        $('#searchForm input[name=pageNo]').val(pageNo);
        $('#searchForm').submit();
    }
</script>
</body>
</html>
